<?php require_once('../Connections/miportal.php');
mysql_query("SET NAMES 'utf8'"); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	
  $logoutGoTo = "../private/login.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "../private/login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_rs_candidato = "-1";
$id_convocatoria="-1";
if (isset($_SESSION['MM_id_target'])) {
  $colname_rs_candidato = $_SESSION['MM_id_target'];
}
if($_SESSION['MM_tp_programa']=="EMPLEATE"){
$q_string_view="asignaciones"	;
$id_convocatoria="19";
}
if($_SESSION['MM_tp_programa']=="EXPERIMENTA"){
$q_string_view="asignaciones"	;
$id_convocatoria="18";
}
if($_SESSION['MM_tp_programa']=="MI PRIMERA EMPRESA"){
$q_string_view="asignacion_mpe"	;
$id_convocatoria="20";
}
if($_SESSION['MM_tp_programa']=="BECAS VINCULACION"){
$q_string_view="asignaciones"	;
$id_convocatoria="17";
}
//QUERY's
mysql_select_db($database_miportal, $miportal);
$query_rs_candidato = sprintf("SELECT * FROM ".$q_string_view." WHERE id_cat_ies = %s AND id_cat_convocatoria=%s ORDER BY id_cor_candidato ASC", GetSQLValueString($colname_rs_candidato, "int"),GetSQLValueString($id_convocatoria, "int"));
$rs_candidato = mysql_query($query_rs_candidato, $miportal) or die(mysql_error());
$row_rs_candidato = mysql_fetch_assoc($rs_candidato);
$totalRows_rs_candidato = mysql_num_rows($rs_candidato);
//Candidatos Incompletos
$query_rs_candidato_inc = sprintf("SELECT * FROM cor_candidato WHERE id_cat_ies = %s AND tp_stat_registro<>4 AND id_convocatoria_activa=".$_SESSION['MM_id_cat_convocatoria']." ORDER BY id_cor_candidato ASC", GetSQLValueString($colname_rs_candidato, "int"));
$rs_candidato_inc = mysql_query($query_rs_candidato_inc, $miportal) or die(mysql_error());
$row_rs_candidato_inc = mysql_fetch_assoc($rs_candidato_inc);
$totalRows_rs_candidato_inc = mysql_num_rows($rs_candidato_inc);

?>
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximun-scale=1">
<title>FUNDACIÓN EDUCACIÓN SUPERIOR-EMPRESA</title>
<!--Hoja de estilo principal-->
<link href="../css/styletd2.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="../css/menu.css"><!--Pemanggilan gambar favicon-->
<link rel="stylesheet" type="text/css" href="../css/mos-style.css">
 <!--pemanggilan file css-->
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script language="JavaScript">
	function confirmar ( mensaje ) {
					return confirm( mensaje );
				}
        </script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
    <div id="background"></div>
    <div class="img_header_logo"></div>
    <span class="img_header_logo"><a href="http://fese.org.mx"><img src="../images/fese/FESE_home_logo.png"  height="90" alt="FESE" align="bottom" /></a></span>
    <div class="img_header_logo"></div>
    <div id="nav">
		<ul>
		  <li class="nivel1"><a href="../private/rov.php" class="nivel1">Inicio</a></li>
		  <li class="nivel1"><a href="../report/report_rov_candidatos.php" class="nivel1">Candidatos</a></li>
          <?php if($_SESSION['MM_tp_programa']!="MI PRIMERA EMPRESA"){
			  echo 
			  		'<li class="nivel1"><a href="../report/report_rov_empresa.php" class="nivel1">Empresas</a></li>';
			 		 }	
		  
		  ?>
		  
		</ul>
	</div><!--Menu NAV-->
</header>
</header>

<center>
<div id="boxcontainer">
<div id="container">
<?php
	if($totalRows_rs_candidato_inc>0){
	 ?>
  <table width="100%" border="1" cellspacing="0" cellpadding="0" summary="Resumen de candidatos y sus asignaciones" style="margin-left:15px;">
    <tr>
      <th class="data" colspan="4" scope="col" style="text-align:center"> REGISTROS INCOMPLETOS</th>
    </tr>
    <tr>
      <th class="data" scope="col">CURP</th>
      <th class="data" scope="col">NOMBRE</th>
      <th class="data" scope="col">ESTATUS DE REGISTRO</th>
      <th class="data" scope="col">CONTINUAR REGISTRO</th>
    </tr>
    <?php
	
	 do {
		 $name= $row_rs_candidato_inc['nb_nom_nombre1']." ".$row_rs_candidato_inc['nb_nom_nombre2']." ".$row_rs_candidato_inc['nb_nom_apaterno']." ".$row_rs_candidato_inc['nb_nom_amaterno']; 
		  ?>
     
      <tr >
        <td class="data"><?php echo $row_rs_candidato_inc['id_cve_curp']; ?></td>
        <td class="data"><?php echo $row_rs_candidato_inc['nb_nom_nombre1']; ?> <?php echo $row_rs_candidato_inc['nb_nom_nombre2']; ?> <?php echo $row_rs_candidato_inc['nb_nom_apaterno']; ?> <?php echo $row_rs_candidato_inc['nb_nom_amaterno']; ?></td>
        <td class="data"><?php echo $row_rs_candidato_inc['tp_stat_registro'];?></td>
        
        <td class="data"><a  href="../form/<?php 
		if($_SESSION['MM_tp_programa']=="MI PRIMERA EMPRESA"&&$row_rs_candidato_inc['tp_stat_registro']=="CANDIDATO"){echo "form_cand_mpe_expediente.php?";}else 
		if($_SESSION['MM_tp_programa']!="MI PRIMERA EMPRESA"&&$row_rs_candidato_inc['tp_stat_registro']=="CANDIDATO"){echo "form_cand_expediente.php?";}else 
		if($_SESSION['MM_tp_programa']=="MI PRIMERA EMPRESA"&&$row_rs_candidato_inc['tp_stat_registro']=="EXPEDIENTE"){echo "form_primaria.php?";}else 
		if($_SESSION['MM_tp_programa']!="MI PRIMERA EMPRESA"&&$row_rs_candidato_inc['tp_stat_registro']=="EXPEDIENTE"){echo "form_empresa.php?";}
		else {echo "error";}
		 ?>user=<?php echo base64_encode($row_rs_candidato_inc['id_cor_candidato']); ?>&name=<?php echo base64_encode($name) ?>">CONTINUAR</a>
       </td>
      </tr>
      <?php } while ($row_rs_candidato_inc = mysql_fetch_assoc($rs_candidato_inc));

	   ?>
  </table>
  <?php
	  }; //FIN DEL IF
	   ?>
  <p>&nbsp;</p>
  
  <p><a href="../form/form_candidato.php"> Ingresar candidato</a><a href="../form/form_candidato.php"><img src="../images/agregar.jpg" alt="Agregar" width="25" height="27"></a></p>
   <?php
	if($totalRows_rs_candidato>0){
	 ?>
  <table width="100%" border="1" cellspacing="0" cellpadding="0" summary="Resumen de candidatos y sus asignaciones" style="margin-left:15px;">
    <tr>
      <th class="data" colspan="7" scope="col" style="text-align:center"> REGISTROS COMPLETOS</th>
    </tr>
    <tr>
      <th class="data" scope="col">NO.</th>
      <th class="data" scope="col">FOLIO</th>
      <th class="data" scope="col">CURP</th>
      <th class="data" scope="col">NOMBRE</th>
      <th class="data" scope="col"><?php if($_SESSION['MM_tp_programa']=="MI PRIMERA EMPRESA"){echo "PRIMARIA";}else {echo "EMPRESA";};?></th>
      <th class="data" scope="col">FORMATOS</th>
      <th class="data" scope="col"><?php if($_SESSION['MM_tp_programa']=="MI PRIMERA EMPRESA"){echo "CAMBIAR PRIMARIA ASIGNADA";}else {echo "CAMBIAR EMPRESA ASIGNADA";};?></th>
    </tr>
    <?php
	$counter=1;
	do {
	$folio=NULL;
	$id_relacion=NULL;
	if($_SESSION['MM_tp_programa']=="MI PRIMERA EMPRESA"){
		$id_relacion=$row_rs_candidato['id_cor_ben_ies_primaria'];
	}else{
		$id_relacion=$row_rs_candidato['id_numRelacion'];
	}
	
	if($_SESSION['MM_tp_programa']=="EMPLEATE"){$folio="EMP".str_pad($row_rs_candidato['id_cor_candidato'],4,0, STR_PAD_LEFT)."13";}else 
											if($_SESSION['MM_tp_programa']=="EXPERIMENTA"){$folio="EXP".str_pad($row_rs_candidato['id_cor_candidato'],4,0, STR_PAD_LEFT)."13";}else 
											if($_SESSION['MM_tp_programa']=="MI PRIMERA EMPRESA"){$folio="MPE".str_pad($row_rs_candidato['id_cor_candidato'],4,0, STR_PAD_LEFT)."13";}else
											if($_SESSION['MM_tp_programa']=="BECAS VINCULACION"){$folio="VBI".str_pad($row_rs_candidato['id_cor_candidato'],4,0, STR_PAD_LEFT)."13";}	
		
		
		 ?>
      <tr >
        <td class="data"><?php echo $counter; ?></td>
        <td class="data"><?php echo $folio; ?></td>
        <td class="data"><?php echo $row_rs_candidato['id_cve_curp']; ?></td>
        <td class="data"><?php echo $row_rs_candidato['nb_nom_nombre1']; ?> <?php echo $row_rs_candidato['nb_nom_nombre2']; ?> <?php echo $row_rs_candidato['nb_nom_apaterno']; ?> <?php echo $row_rs_candidato['nb_nom_amaterno']; ?></td>
        <td class="data"><?php if($_SESSION['MM_tp_programa']=="MI PRIMERA EMPRESA"){echo $row_rs_candidato['nb_primaria'];}else {echo $row_rs_candidato['id_nom_fiscal'];};?></td>
        
        <td class="data"><a target="_blank" href="../form/carta_<?php if($_SESSION['MM_tp_programa']=="EMPLEATE"){echo "empleate.php?";}else 
											if($_SESSION['MM_tp_programa']=="EXPERIMENTA"){echo "experimenta.php?";}else 
											if($_SESSION['MM_tp_programa']=="MI PRIMERA EMPRESA"){echo "mpe.php?";}else
											if($_SESSION['MM_tp_programa']=="BECAS VINCULACION"){echo "bv.php?";}
									 ?>id=<?php echo $row_rs_candidato['id_cve_curp']; ?>">CARTA COMPROMISO </a>
       <br>
        <a  rel="parent" target="_blank" href="../form/expediente_<?php if($_SESSION['MM_tp_programa']=="EMPLEATE"){echo "emp.php?";}else 
											if($_SESSION['MM_tp_programa']=="EXPERIMENTA"){echo "exp.php?";}else 
											if($_SESSION['MM_tp_programa']=="MI PRIMERA EMPRESA"){echo "mpe.php?";}else
											if($_SESSION['MM_tp_programa']=="BECAS VINCULACION"){echo "bv.php?";}
									 ?>id=<?php echo $row_rs_candidato['id_cve_curp']; ?>"> FORMATO EXPEDIENTE</a></td>

	<td class="data"><?php if($row_rs_candidato['tp_status_validacion']==0){echo "<a onClick=\"return confirmar('¿Esta seguro que desea eliminar la postulación del candidato: ".$row_rs_candidato['nb_nom_nombre1']." ".$row_rs_candidato['nb_nom_nombre1']." ".$row_rs_candidato['nb_nom_apaterno']." ".$row_rs_candidato['nb_nom_amaterno']."?')\" href='valida_candidato.php?rel=".base64_encode($id_relacion)."&id_convocatoria=".$_SESSION['MM_id_cat_convocatoria']."&id_ben=".base64_encode($row_rs_candidato['id_cor_candidato'])."'>CAMBIAR</a>";}else{echo "Validado";}; ?> 
		</td>  
      </tr>
      
          
      
      <?php 
	  $counter++;
	  } while ($row_rs_candidato = mysql_fetch_assoc($rs_candidato));

	   ?>
  </table>
  <?php
	  }; //FIN DEL IF
	   ?>
<p>&nbsp;</p>

 
</div>
<!--Container-->
<div id="rightContainer">
    <div id="Bienvenida">
    <div id="cuadro">
    <h1>Bienvenido</h1>
    </div>
    
    <div >
    <br>
            <?php echo $_SESSION['MM_UsName'] ?><br><br>
            <?php echo $_SESSION['MM_nmb_target'] ?><br>
            <a href="<?php echo $logoutAction ?>">Salir</a>
            </div>
    </div>
    <br style="clear:both"/>
    <div id="convocatoria">
    <div id="cuadro">
    <h1>Convocatoria</h1>
    </div>
    <br>
    <?php 
    if(isset($_SESSION['MM_tp_programa'])&$_SESSION['MM_tp_programa']=="Vigentes"){
        echo "<select name=\"slConvocatoria\">
        <option selected=\"selected\">Seleccione</option>
        <option value=\"empleate\">Empleate</option>
        <option value=\"experimenta\">Experimenta</option>
        <option value=\"mpe\">Mi Primera Empresa</option>
        <option value=\"vecas_vinculacion\">Vecas Vinculación</option>
        </select>
        "	;
    }else{
    echo $_SESSION['MM_tp_programa'];}
    ?>
    
    </div>
</div><!--contenedor derecho-->


</div><!--Boxcontainer-->
 
   
</center>

  
  
</body>
</html>
<?php
mysql_free_result($rs_candidato);
?>
